﻿using Abp.Application.Services.Dto;
using Abp.AutoMapper;
using SingleUserMall.Items;
using SingleUserMall.Orders;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SingleUserMall.Refunds.VO
{
    [AutoMapFrom(typeof(Refund))]
    public class RefundVO:EntityDto<long>
    {
        internal Order inOrder { get; set; }
        internal Item inItem { get; set; }
        internal ItemSpec inItemSpec { get; set; }
        internal OrderDetail inOrderDetail { get; set; }
        /// <summary>
        /// 订单id
        /// </summary>
        public long OrderId { get; set; }
        /// <summary>
        /// 处理方式
        /// </summary>
        public RefundType Type { get; set; }
        /// <summary>
        /// 处理方式名称
        /// </summary>
        public string TypeView => Type.GetDescription();
        /// <summary>
        /// 货物状态
        /// </summary>
        public ItemStatus? ItemStatus { get; set; }
        /// <summary>
        /// 货物状态名称
        /// </summary>
        public string ItemStatusView => ItemStatus?.GetDescription();
        /// <summary>
        /// 退款编号
        /// </summary>
        public string RefundNo { get; set; }
        /// <summary>
        /// 退款原因
        /// </summary>
        public string Reason { get; set; }
        /// <summary>
        /// 退款金额
        /// </summary>
        public decimal Amount { get; set; }
        /// <summary>
        /// 手机号码
        /// </summary>
        public string PhoneNumber { get; set; }
        /// <summary>
        /// 备注
        /// </summary>
        public string Remark { get; set; }
        /// <summary>
        /// 凭证
        /// </summary>
        public string Vouchers { get; set; }
        /// <summary>
        /// 退款状态
        /// </summary>
        public RefundStatus Status { get; set; }
        /// <summary>
        /// 退款状态名称
        /// </summary>
        public string StatusView => Status.GetDescription();
        /// <summary>
        /// 关闭原因
        /// </summary>
        public string CloseReason { get; set; }
        /// <summary>
        /// 结束时间
        /// </summary>
        public DateTime? FinishTime { get; set; }
        /// <summary>
        /// 订单编号
        /// </summary>
        public string OrderNo => inOrder?.OrderNo;
        /// <summary>
        /// 商品图片
        /// </summary>
        public string ItemPicture => inItem?.Picture;
        /// <summary>
        /// 商品名称
        /// </summary>
        public string ItemName => inItem?.Name;
        /// <summary>
        /// 规格
        /// </summary>
        public string Spec => inItemSpec?.Spec;
        /// <summary>
        /// 单价
        /// </summary>
        public decimal Price => inItemSpec?.Price??0;
        /// <summary>
        /// 数量
        /// </summary>
        public int Qty => inOrderDetail?.Qty ?? 0;
        /// <summary>
        /// 价格合计
        /// </summary>
        public decimal TotalPrice => Price * Qty;
        /// <summary>
        /// 处理时间
        /// </summary>
        public DateTime? RefundTime { get; set; }
        /// <summary>
        /// 申请时间
        /// </summary>
        public DateTime CreationTime { get; set; }
    }
}
